package net.xxcl.kygl.service;

import java.util.List;
import net.xxcl.kygl.mapper.MoneyMapper;
import net.xxcl.kygl.mapper.ProjectMapper;
import net.xxcl.kygl.pojo.Criteria;
import net.xxcl.kygl.pojo.Money;
import net.xxcl.kygl.pojo.Project;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional()
public class MoneyService {
    @Autowired
    private MoneyMapper moneyMapper;
    @Autowired
    private ProjectMapper projectMapper;

    private static final Logger logger = LoggerFactory.getLogger(MoneyService.class);

    public int countByExample(Criteria example) {
        int count = this.moneyMapper.countByExample(example);
        logger.debug("count: {}", count);
        return count;
    }

    public Money selectByPrimaryKey(Integer id) {
        return this.moneyMapper.selectByPrimaryKey(id);
    }

    public List<Money> selectByExample(Criteria example) {
        return this.moneyMapper.selectByExample(example);
    }

    public int deleteByPrimaryKey(Integer id) {
        return this.moneyMapper.deleteByPrimaryKey(id);
    }

    public int updateByPrimaryKeySelective(Money record) {
        return this.moneyMapper.updateByPrimaryKeySelective(record);
    }

    public int updateByPrimaryKey(Money record) {
        return this.moneyMapper.updateByPrimaryKey(record);
    }

    public int deleteByExample(Criteria example) {
        return this.moneyMapper.deleteByExample(example);
    }

    public int updateByExampleSelective(Money record, Criteria example) {
        return this.moneyMapper.updateByExampleSelective(record, example);
    }

    public int updateByExample(Money record, Criteria example) {
        return this.moneyMapper.updateByExample(record, example);
    }

    public int insert(Money record) {
        return this.moneyMapper.insert(record);
    }

    public int insertSelective(Money record) {
        return this.moneyMapper.insertSelective(record);
    }

    public int reduce(Money money,Project project) {
        projectMapper.updateByPrimaryKeySelective(project);
        return this.moneyMapper.insertSelective(money);
    }
}